<%@ page import="cn.edu.swu.Item" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.edu.swu.DBUtils" %>
<%@ page import="cn.edu.swu.PageUtils" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.sql.SQLException" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html lang="en" xmlns:color="http://www.w3.org/1999/xhtml">
<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
	<meta name="description" content="" />
	<meta name="author" content="" />
	<title>BUFF store</title>
	<!-- Favicon-->
	<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
	<!-- Bootstrap icons-->
	<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" />
	<!-- Core theme CSS (includes Bootstrap)-->
	<link href="css/styles.css" rel="stylesheet" />
</head>
<body>
<!-- Navigation-->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
	<div class="container px-6 px-lg-6">
		<a class="navbar-brand" >菜单栏</a>
		<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
		<div class="collapse navbar-collapse" id="navbarSupportedContent">
			<ul class="navbar-nav me-auto mb-2 mb-lg-0 ms-lg-4">
				<li class="nav-item"><a class="nav-link active" aria-current="page" href="/myapp/admin/atest.jsp">首页</a></li>
				<li class="nav-item"><a class="nav-link active" aria-current="page" href="/myapp/admin/admin.html">管理</a></li>
				<li class="nav-item"><a class="nav-link" href="#!">搜索</a></li>
				<li class="nav-item dropdown">
					<a class="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">饰品</a>
					<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
						<li><a class="dropdown-item" >磨损分类</a></li>
						<li><hr class="dropdown-divider" /></li>
						<li><a class="dropdown-item" href="#!">崭新出厂</a></li>
						<li><a class="dropdown-item" href="#!">略有磨损</a></li>
						<li><a class="dropdown-item" href="#!">久经沙场</a></li>
						<li><a class="dropdown-item" href="#!">破损不堪e</a></li>
					</ul>
				</li>
			</ul>
			<button class="btn btn-outline-dark" >
				<a class="nav-item text-decoration-none color:#fff " aria-current="page"  href='/myapp/logout'>登 出</a>
			</button>
		</div>
	</div>
</nav>
<!-- Header-->
<header class="bg-dark py-5">
	<div class="container px-4 px-lg-5 my-5">
		<div class="text-center text-white">
			<h1 class="display-4 fw-bolder">BUFF饰品交易市场</h1>
			<p class="lead fw-normal text-white-50 mb-0">你想要的，这里都有！</p>
		</div>
	</div>
</header>
<!-- Section-->
<section class="py-5">
	<div class="container px-4 px-lg-5 mt-5">
		<center>
			<%
				String id = request.getParameter("id");
				String sql = "SELECT * FROM aitems WHERE id=" + id;
				try {
					List<Item> items = DBUtils.getItems(sql);
					if (items.size() == 0) {
						response.sendRedirect("./edit.jsp");
						return;
					}
					Item item= items.get(0);

			%>
			<form action="./updateItem" method="POST" enctype="multipart/form-data">
				<table>
					<tr><td>名称</td><td><input type='text' name=name value='<%=item.getName()%>'></td></tr>
					<tr><td>模板</td><td><input type='text' name=template value='<%=item.getTemplate()%>'></td></tr>
					<tr><td>价格: </td><td><input type='text' name=price  value='<%=item.getPrice()%>'></td></tr>
					<tr><td>类别: </td><td>
						<select name='type'>
							<option value='崭新出厂'>崭新出厂
							<option value='略有磨损'>略有磨损
							<option value='久经沙场'>久经沙场
							<option value='战痕累累'>破损不堪
							<option value='破损不堪'>破损不堪
						</select>
					</td></tr>
					<tr><td>描述: </td><td><textarea name='describe' cols='50' rows='5'><%=item.getDescribe()%></textarea></td></tr>
					<tr><td colspan="2" align="center"><br><input type='submit' value="修改"></td></tr>
				</table>
			</form>
		</center>
	</div>
</section>
 <%
     } catch (SQLException e) {
	  e.printStackTrace();
	 }
	%>
<!-- Footer-->
<footer class="py-5 bg-dark">
	<div class="container"><p class="m-0 text-center text-white">by 周文铭迪</p></div>
</footer>
<!-- Bootstrap core JS-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Core theme JS-->
<script src="js/scripts.js"></script>
</body>
</html>
